using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MultiVMR9cs;

namespace Sample
{
    public partial class VideoOutputForm : Form
    {
        private MultiVMR9Panel _panel;

        public VideoOutputForm()
        {
            InitializeComponent();

            // populate the adapter and display mode combo boxes
            for (int i = 0; i < MultiVMR9Panel.Adapters; i++)
            {
                _adapterComboBox.Items.Add("Adapter " + i.ToString());
            }
            _adapterComboBox.SelectedIndex = 0;

            // get the default display adapter and mode
            VMR9DisplayMode mode = _displayModeComboBox.SelectedItem as VMR9DisplayMode;

            // create and add the MultiVMR9Panel
            _panel = new MultiVMR9Panel(mode);

            _panel.Dock = DockStyle.Fill;
            Controls.Add(_panel);
            Controls.SetChildIndex(_panel, 0);
            this.ClientSize = new Size(mode.Width / 2, mode.Height / 2);

            _fullScreenModeComboBox.SelectedIndex = 0;
        }

        public MultiVMR9Panel MultiVMR9Panel
        {
            get
            {
                return _panel;
            }
        }

        private void _adapterComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            _displayModeComboBox.Items.Clear();

            foreach (VMR9DisplayMode mode in MultiVMR9Panel.GetDisplayModes(_adapterComboBox.SelectedIndex))
            {
                _displayModeComboBox.Items.Add(mode);
            }
            _displayModeComboBox.SelectedIndex = 0;
        }

        private void _resetDeviceButton_Click(object sender, EventArgs e)
        {
            VMR9DisplayMode mode = _displayModeComboBox.SelectedItem as VMR9DisplayMode;
            mode.FullScreenMode = (FullScreenMode)_fullScreenModeComboBox.SelectedIndex;
            _panel.ResetDevice(mode);
        }
    }
}